-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
src/index.js
Outdated
if (this._peers[peerInfo.id.toB58String()] && !replace) { | ||
// peerInfo.replace merges by default if none to replace are passed | ||
this._peers[peerInfo.id.toB58String()] | ||
.multiaddrs.replace([], peerInfo.multiaddrs.toArray()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not do what we want, as I said before what I need is to merge both sets of multiaddrs, which this does not do in my tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/index.js
Outdated
// peerInfo.replace merges by default | ||
peers[peerInfo.id.toB58String()].multiaddr.replace([], peerInfo.multiaddrs) | ||
/** | ||
* Stores a peerInfo, if already exist, only adds the multiaddrs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also need public and private keys to be added if I put an existing one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more thing, it would be great if it could return the merged result, as I currently have to do this
// got info from the network
peerBook.put(info)
const correctInfo = peerBook.get(info)
// after
const correctInfo = peerBook.put(info)
let info
try {
info = peerBook.get(id)
} catch(err) {
info = new PeerInfo(id)
} |
src/index.js
Outdated
@@ -29,30 +34,31 @@ function PeerBook () { | |||
* @param {PeerId} id | |||
* @returns {PeerInfo} | |||
*/ | |||
this.get = (id) => { | |||
get (id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this could accept PeerInfos
as well, that would be nice
|
@dignifiedquire did more changes than requested, but I think you will be pleased :) (still checking all the tests, because you know.. npm installs) |
src/index.js
Outdated
* | ||
* @param {PeerInfo} peerInfo | ||
* @param {replace} boolean | ||
* @returns {null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would love to see the one put into the book to be returned here
df2d734
to
e787a6e
Compare
e787a6e
to
d82da99
Compare
No description provided.